package arithmetic1.demo;

import java.util.Scanner;

public class IntegerBinary {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String string1 = scanner.nextLine();
		int n = Integer.parseInt(string1.split(" ")[0]);
		int q = Integer.parseInt(string1.split(" ")[1]);
		String string2 = scanner.nextLine();
		String[] strings = string2.split(" ");
		int[] arr = new int[n];
		for(int i=0;i<n;i++) {
			arr[i] = Integer.parseInt(strings[i]);
		}
		int qs[] = new int[q];
		for(int i=0;i<q;i++) {
			qs[i] = scanner.nextInt();
		}
		for(int i=0;i<q;i++){
			int l = 0;
			int r = n-1;
			//����߽�
			while(l<r) {
				int mid = (l+r)>>1;
				if(arr[mid]>=qs[i]) {
					r = mid;
				}else {
					l = mid+1;
				}
			}
			if(arr[l]!=qs[i]) {
				System.out.println("-1 -1");
			}else {
				System.out.print(l+" ");
				 l = 0;
				 r = n-1;
				 //���ұ߽�
				 while(l<r) {
					int mid = (l+r+1)>>1;
				 	if(arr[mid]<=qs[i]) {
				 		l = mid;
				 	}else {
				 		r = mid-1;
				 	}
				 }
				 System.out.println(l);
			}
		}
	}


}
